﻿using System;
using System.Data;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
namespace AnyOffice.general.system.workflow.flow_form
{
    public partial class form_edit : ModulePage
    {        
        private int form_id;     

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.form_id = (Request.QueryString["form_id"] == null) ? 0 : int.Parse(Request.QueryString["form_id"].ToString());
                this.ViewState["FormId"] = this.form_id;
                DataTable table = new FlowFormTypeDao().SelectByFormId(base.Conn, this.form_id);
                if (table.Rows.Count > 0)
                {
                    if (Convert.ToBoolean(table.Rows[0]["CanDelete"]))
                    {
                        this.hlinkDelete.NavigateUrl = "javascript:delete_form(" + this.form_id.ToString() + ");";
                        this.hlinkDelete.Visible = true;
                    }
                    this.txtFormName.Text = table.Rows[0]["FormName"].ToString();
                }
            }
            if (this.Page.IsPostBack)
            {
                FlowFormTypeDao dao2 = new FlowFormTypeDao();
                FlowFormTypeData data = new FlowFormTypeData();
                this.form_id = Convert.ToInt32(this.ViewState["FormId"]);
                data.FormId = this.form_id;
                data.FormName = this.txtFormName.Text;
                dao2.UpdateName(base.Conn, data);
                base.CloseConn();
                Response.Redirect("index.aspx");
            }
        }
        
    }
}

